
disableSerialization;

_gmable=player getVariable "GMABLE";If ( player!=user1) then {if (isnil "_gmable") then {killscript=true;breakclic=0;};}; if (killscript) exitwith {killscript=false;};

//Début de script OnmapClick
if  (breakclic <= 1 ) then
{
	clic1 = false;

	_display = finddisplay 8000;
	_txt = _display displayctrl 200;

	_txt CtrlSetText "Left click on the map";
	_txt CtrlSetTextColor [0.9,0.9,0.9,1];

	Ctrlshow [200,true];sleep 0.2; CtrlShow [200,false];sleep 0.2;Ctrlshow [200,true];

  //Récuperation des coordonnées de la carte
	onMapSingleClick "spawn_x = _pos select 0;
		spawn_y = _pos select 1;
		spawn_z = _pos select 2;
		publicVariable ""spawn_x"";
		publicVariable ""spawn_y"";
		publicVariable ""spawn_z"";
		
		clic1 = true;
		
	onMapSingleClick """";";
		for "_j" from 10 to 0 step -1 do 
		{
		hint format["Click On Map %1, or wait for cancellation",_j];
		sleep 1;
		//hint "pause";
		
			//if (_clic1) exitWith {};
			if (clic1) then
			{
				hint "";
				_j=0;
				clic1 = false;
				_posclick = [spawn_x,spawn_y,spawn_z];
				_marker_Take = createMarkerLocal ["Nmarker",_posclick];
				_marker_Take setMarkerShapeLocal "ELLIPSE";
				//		_marker_Take setMarkerTypeLocal "Dot";
				_marker_Take setMarkerSizeLocal [25, 25];
				_marker_Take setMarkerDirLocal 0;
				_marker_Take setMarkerColorLocal "ColorredAlpha";
				
        //******************************
        //***** Code come here *********
				//******************************
				
			
				  haloc130 = createVehicle ["C130J", [spawn_x, spawn_y, spawn_z + 10000], [], 0, "FLY"];
				  _groupPilot = createGroup civilian;
  			  _pilotc1301 = "RU_Pilot" createUnit [[spawn_x,spawn_y,0], _groupPilot,"this assignasdriver haloc130;this moveindriver haloc130",0.5,"corporal"];
  			  _pilotc1302 = "RU_Pilot" createUnit [[spawn_x,spawn_y,0], _groupPilot,"this assignascargo haloc130;this moveincargo haloc130",0.5,"corporal"];
  			  _pilotc1303 = "RU_Pilot" createUnit [[spawn_x,spawn_y,0], _groupPilot,"this assignascargo haloc130;this moveincargo haloc130",0.5,"corporal"];
   				haloc130 setpos [spawn_x, spawn_y, spawn_z + 10000]; 
  				haloc130 flyInHeight 10000;
          haloc130 setCaptive true;
          haloc130 lock true;
          _WP = _groupPilot addWaypoint [getpos haloc130, 100];
          _WP setWaypointType "HOLD";
          publicVariable "haloc130";
     
        
          sleep 1;
        
        
        for [{_i=1},{_i<=nbre_joueursX},{_i=_i+1}] do
        {
           call compile format ["
           if (alive user%1) then { if (vehicle user%1!=user%1) then {moveout user%1};};
           ",_i];
        };        
  
        sleep 0.5;
        
        
      
        for [{_i=1},{_i<=nbre_joueursX},{_i=_i+1}] do
        {
           //{player assignascargo haloc130; player moveinCargo haloc130;} foreach player_units;
           _code=compile format["if (player==user%1) then {cutText ["""",""BLACK OUT"",1];sleep 1;cutText ["""",""BLACK IN"",2];player assignascargo haloc130; player moveInCargo haloc130;haloc130 addaction [""Jump Out"",""scripts\VTS_Functions\halojumpout.sqf""];clearWeaponCargo  haloc130;if (ACEMOD) then {haloc130 addWeaponCargo [""ACE_ParachutePack"",50]};};",_i];
           [_code] execVM "scripts\VTS_Functions\runcodeonallclients.sqf";
           //call compile format ["
           //if (alive user%1) then {user1 sidechat ""%1"";user%1 assignascargo haloc130; user%1 moveInCargo haloc130;};
           sleep 0.75;
           //",_i];
        };        
        
        
        /*
        codetorun={
        player assignascargo haloc130; player moveinCargo haloc130;
        };
        [codetorun] execVM "scripts\VTS_Functions\runcodeonallclients.sqf";
        */
        sleep 0.5;
        
        //******************************
				//******************************
			
      	sleep 1;
				deletemarker "Nmarker";
								
			};
			clic1 = false;
	}; 
		sleep 0.25;
		hint "";
		breakclic = 0; 
		//	waitUntil {(clic1)};
};
If (true) ExitWith {};
